import { defineStore } from "pinia";
import { reqHospitalDetail,reqHospitalDeparment } from "@/api/hospital/index";
import type { HospitalDetail,HosPitalDetail,DeparmentResponseData } from "@/api/hospital/type";
import type {DetailState} from '@/store/modules/type'
const useDetailStore = defineStore("hospitalDetail", {
  state:():DetailState=>{
    return{
      hospitalInfo:({} as HosPitalDetail),
      deparmentArr:[]
    }
  },
  getters: {},
  actions: {
    async getHospital(hoscode: string) {
      let res: HospitalDetail = await reqHospitalDetail(hoscode);
      if (res.code == 200) {
        (this.hospitalInfo as any) = res.data
      }
    },
    async getDeparment(hoscode: string){
      let res:DeparmentResponseData = await reqHospitalDeparment(hoscode)
      if(res.code==200){
        this.deparmentArr = res.data
      }
    }
  },
});
export default useDetailStore;
